//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================


#if _MSC_VER > 1000
#pragma once
#endif

#ifndef __bufio_h__
#define __bufio_h__

//#ifdef __cplusplus
//extern "C"{
//#endif

/* Forward Declarations */

#ifndef __IBufioDriver_FWD_DEFINED__
#define __IBufioDriver_FWD_DEFINED__
typedef interface IBufioDriver IBufioDriver;
#endif     /* __IBufioDriver_FWD_DEFINED__ */
//#ifndef                 FILE_FLAGS
typedef UInt32            FILE_FLAGS
//#endif



#ifndef __IBufioDriver_INTERFACE_DEFINED__
#define __IBufioDriver_INTERFACE_DEFINED__

/* interface IBufioDriver */
/* [unique][uuid][local][object] */


EXTERN_C const InterfaceID EIID_IBufioDriver;

#if defined(__cplusplus) && !defined(CINTERFACE)

    MIDL_INTERFACE("836b77a3-14b2-473a-a83b-bc106c0ab9b9")
    IBufioDriver : public IZFile
    {
    public:
        virtual CARAPI map(
            void **out_addr,
            UInt32 offset,
            Int32 count) = 0;

        virtual CARAPI unmap(
            void *addr,
            UInt32 offset,
            Int32 count) = 0;

        virtual CARAPI wire(
            UInt32 *out_phys_addr,
            UInt32 offset,
            Int32 count) = 0;

        virtual CARAPI unwire(
            UInt32 phys_addr,
            UInt32 offset,
            Int32 count) = 0;

    };

#else     /* C style interface */

    typedef struct IBufioDriverVtbl
    {

        PInterface (CARAPICALLTYPE *Probe )(
            IBufioDriver * This,
            /* [in] */ REIID riid);

        UInt32 (CARAPICALLTYPE *AddRef )(
            IBufioDriver * This);

        UInt32 (CARAPICALLTYPE *Release )(
            IBufioDriver * This);

        ECode (CARAPICALLTYPE *ReadAt )(
            IBufioDriver * This,
            UInt64 Position,
            /* [length_is][size_is][out] */ byte *pBuffer,
            UInt32 Size,
            /* [unique][out][in] */ UInt32 *pSizeRead);

        ECode (CARAPICALLTYPE *WriteAt )(
            IBufioDriver * This,
            UInt64 Position,
            /* [size_is][in] */ const byte *pBuffer,
            UInt32 Size,
            /* [unique][out][in] */ UInt32 *pSizeWritten);

        ECode (CARAPICALLTYPE *SetSize )(
            IBufioDriver * This,
            UInt64 Size);

        ECode (CARAPICALLTYPE *GetSize )(
            IBufioDriver * This,
            /* [out] */ UInt64 *pSize);

        ECode (CARAPICALLTYPE *CreateStream )(
            IBufioDriver * This,
            UInt64 Position,
            UInt64 Size,
            FILE_FLAGS Flags,
            /* [out] */ IStream **ppStream);

        ECode (CARAPICALLTYPE *Flush )(
            IBufioDriver * This);

        ECode (CARAPICALLTYPE *map )(
            IBufioDriver * This,
            void **out_addr,
            UInt32 offset,
            Int32 count);

        ECode (CARAPICALLTYPE *unmap )(
            IBufioDriver * This,
            void *addr,
            UInt32 offset,
            Int32 count);

        ECode (CARAPICALLTYPE *wire )(
            IBufioDriver * This,
            UInt32 *out_phys_addr,
            UInt32 offset,
            Int32 count);

        ECode (CARAPICALLTYPE *unwire )(
            IBufioDriver * This,
            UInt32 phys_addr,
            UInt32 offset,
            Int32 count);

    } IBufioDriverVtbl;

    interface IBufioDriver
    {
        CONST_VTBL struct IBufioDriverVtbl *v;
    };



#ifdef COBJMACROS


#define IBufioDriver_Probe(This,riid)    \
    (This)->v -> Probe(This,riid)

#define IBufioDriver_AddRef(This)    \
    (This)->v -> AddRef(This)

#define IBufioDriver_Release(This)    \
    (This)->v -> Release(This)


#define IBufioDriver_ReadAt(This,Position,pBuffer,Size,pSizeRead)    \
    (This)->v -> ReadAt(This,Position,pBuffer,Size,pSizeRead)

#define IBufioDriver_WriteAt(This,Position,pBuffer,Size,pSizeWritten)    \
    (This)->v -> WriteAt(This,Position,pBuffer,Size,pSizeWritten)

#define IBufioDriver_SetSize(This,Size)    \
    (This)->v -> SetSize(This,Size)

#define IBufioDriver_GetSize(This,pSize)    \
    (This)->v -> GetSize(This,pSize)

#define IBufioDriver_CreateStream(This,Position,Size,Flags,ppStream)    \
    (This)->v -> CreateStream(This,Position,Size,Flags,ppStream)

#define IBufioDriver_Flush(This)    \
    (This)->v -> Flush(This)


#define IBufioDriver_map(This,out_addr,offset,count)    \
    (This)->v -> map(This,out_addr,offset,count)

#define IBufioDriver_unmap(This,addr,offset,count)    \
    (This)->v -> unmap(This,addr,offset,count)

#define IBufioDriver_wire(This,out_phys_addr,offset,count)    \
    (This)->v -> wire(This,out_phys_addr,offset,count)

#define IBufioDriver_unwire(This,phys_addr,offset,count)    \
    (This)->v -> unwire(This,phys_addr,offset,count)

#endif /* COBJMACROS */


#endif     /* C style interface */












#endif     /* __IBufioDriver_INTERFACE_DEFINED__ */


/* interface __MIDL_itf_bufio_0017 */
/* [local] */

typedef IBufioDriver * PIVGADRIVER;
#define CMBUFIODRIVER ((sizeof(IBUFIODriverVtbl))/sizeof(METHOD))



/* Additional Prototypes for ALL interfaces */

/* end of Additional Prototypes */

//#ifdef __cplusplus
//}
//#endif

#endif
